<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="validausuario.jsp"%>
<%@ page import="com.are.manejadores.*"%>
<%@ page import="com.are.entidades.*"%>
<%@ page import="java.util.*"%>
<%
	db conexion = new db();
	
	String codigo = (String)request.getParameter("codigo");
	ManejadorAvances MA = new ManejadorAvances(conexion);
	if (request.getParameter("cmd_agregar") != null) {
		String cadena = (String)request.getParameter("avance");
		String usuario = (String)session.getAttribute("usuario");
		Avance avance = new Avance();
		avance.setAvance(cadena);
		avance.setUsuario(usuario);
		avance.setOrden(codigo);
		MA.Add(avance);
	}
	
	
	
	ArrayList<Avance> lista = MA.List(codigo);
	int fila = 1;

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Avances orden</title>
<link rel="stylesheet" href="themes/redmond/jquery.ui.all.css">
<link rel="stylesheet" TYPE="text/css" HREF="main.css">
<script src="js/jquery.js" type="text/javascript"></script>
<script src="ui/jquery.ui.core.js" language="JavaScript"></script>
<script src="ui/jquery.ui.widget.js" language="JavaScript"></script>
<script src="ui/jquery.ui.button.js"></script>
<script type="text/javascript">
$(function() {
	$( "input:submit, a, button", ".demo" ).button();
	$( "input:button, a, button", ".demo" ).button();
});
</script>
<script language="javascript"> 
$(document).ready(function() { 
     $(".botonExcel").click(function(event) { 
     $("#datos_a_enviar").val( $("<div>").append( $("#Exportar_a_Excel").eq(0).clone()).html()); 
     $("#FormularioExportacion").submit(); 
	}); 
}); 
</script>
</head>
<body>
<div class="contenedor">
<%@include file="header.jsp"%>
<div class="contencenter demo">
<h2>Avances</h2>
ID SISCOS: <%= (String)request.getParameter("codigo") %> 
<form name="form1" method ="get" action="avances.jsp">
<table>
	<tr>
		<th>NUEVO AVANCE</th>
	</tr>
	<tr>
		<td><textarea rows="5" cols="100" name="avance" id="avance"></textarea><input type="hidden" name="codigo" value="<%= (String)request.getParameter("codigo")  %>"></td>
	</tr>
	<tr>
		<td><input type="submit" name="cmd_agregar" value="Agregar"></td>
	</tr>
</table>

</form>
<form action="ExportExcel.jsp" method="post" target="_blank" id="FormularioExportacion">
	<p>Exportar a Excel  <img src="images/Download.png" class="botonExcel" /></p> 
	<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" /> 
	</form>
	<table>
	<tr id="Exportar_a_Excel">
		<th>Fecha</th>
		<th>Usuario</th>
		<th>Avance</th>
	</tr>
	<% for (Avance item : lista) { %>
	<tr <%= fila%2==0?"class='odd'":"" %>>
		<td><%= item.getFecha() %></td>
		<td><%= item.getUsuario() %></td>
		<td><%= item.getAvance() %></td>
	</tr>
	
	<% fila++; %>
	<% } %>
	<tr <%= fila%2==0?"class='odd'":"" %>>
		<td colspan="13">Total Avances: <%= lista.size() %></td>
	</tr>
</table>
</div>
<%@include file="foot.jsp"%>
</div>
</body>
</html>
<%
	conexion.Close();
%>